package LC.nums.remove;

public class LC26 {
    public static void main(String[] args) {

    }

    /**
     * @param nums
     * @return
     */
    public int removeDuplicates(int[] nums) {
        int slowIndex = 0, fastIndex = 1;
        if (nums == null || nums.length == 0) return 0;
        while (fastIndex < nums.length) {
            if (nums[slowIndex] != nums[fastIndex]) {
                if (fastIndex - slowIndex > 1) {
                    nums[slowIndex + 1] = nums[fastIndex];
                }
                slowIndex++;
            }
            fastIndex++;
        }
        return slowIndex + 1;
    }
}
